/**wait*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<unistd.h>
#include<signal.h>
#include<sys/types.h>
#include<sys/wait.h>

int main(void)
{
	switch(fork()){
		case -1:
			perror("fork error");
			exit(-1);
		case 0:
			printf("child process start:\n");
			printf("child print info:%d\n",getpid());
			printf("~~~~~~~~~~~~~~~~~\n");
			//_exit(0);
			//abort();
			while(1){
				sleep(1);
			}
			return 10;
		default:
			printf("parent process start\n");
			printf("parent print info\n");
			int ret;
			int status;
			ret=wait(&status);
			if(-1==ret){
				perror("wait error");
				return 1;
			}
			printf("%d,%d\n",ret,WIFEXITED(status));
			printf("%d,%d\n",ret,WEXITSTATUS(status));
			printf("%d,%d\n",ret,WIFSIGNALED(status));
			printf("%d,%d\n",ret,WTERMSIG(status));
			exit(0);
	}
}
